package com.sky.service.impl;

import com.sky.result.Result;
import com.sky.service.ShopService;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;

@Service
@Slf4j
public class ShopServiceImpl implements ShopService {

    private static final String SHOP_STATUS = "SHOP_STATUS";
    @Autowired
    private RedisTemplate redisTemplate;
    /**
     * 设置店铺状态
     *
     * @param status 店铺状态：1 营业中 ，2 打烊中
     * @return
     */
    public Integer setStatus(Integer status) {
        ValueOperations valueOperations = redisTemplate.opsForValue();
        valueOperations.set(SHOP_STATUS,status);
        return status;
    }

    /**
     * 获取店铺营业状态
     * @return 店铺状态：1 营业中 ，2 打烊中
     */
    public Integer getStatus() {
        ValueOperations valueOperations = redisTemplate.opsForValue();
        Integer shopStatus = (Integer) valueOperations.get(SHOP_STATUS);
        return shopStatus;
    }
}
